package com.example.demo.demos.service.impl;

import com.example.demo.demos.service.UserService;
import com.example.demo.demos.entity.User;
import com.example.demo.demos.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserRepository userRepository;

    @Override
    public User getUserById(Long id) {
        return userRepository.findById(id).orElse(null);
    }

    @Override
    public List<User> getAllUsers() {
        return userRepository.findAll();
    }

    @Override
    public void saveUser(User user) {
        userRepository.save(user);
    }

    @Override
    public boolean hasPermission(String username, String path) {
        // 假设有UserPermission表和对应的JPA Repository
        // 这里仅做示例，实际可根据你的权限表结构实现
        // return userPermissionRepository.existsByUsernameAndPath(username, path);
        return true; // 示例：默认有权限
    }
}
